
package com.cxx.purchasecharge.core.config;

import java.util.Collection;

import org.apache.log4j.Logger;

public class CxxPropertiesFactory
{
    private static final Logger   logger                     = Logger.getLogger(CxxPropertiesFactory.class);

    /** instance of current properties implementation */
    private static ICxxProperties s_cfgProperties;

    static
    {
        s_cfgProperties = new CxxPropertiesImpl();
    }

    /**
     * Returns the ICfgProperties implementation
     * 
     * @return ICfgProperties
     */
    public static ICxxProperties getInstance()
    {
        return s_cfgProperties;
    }

    /**
     * Returns the CxxProperties for the specified group.
     * 
     * @param groupName
     * @return A CxxProperties instance for the group.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupName is null or empty
     */
    public static CxxProperties getProperties(String groupName) throws ConfigException
    {
        return s_cfgProperties.getProperties(groupName);
    }

    /**
     * Returns the CxxProperties for the specified group, using the filepath as the directory to
     * retrieve the properties. The filepath is only used for file-based implementations. In the
     * config server implementation the filepath is ignored.
     * 
     * @param filePath
     * @param groupName
     * @return A CxxProperties instance for the group.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupName is null or empty
     * @throws IllegalArgumentException
     *             if filePath is null or empty
     */
    public static CxxProperties getProperties(String filePath, String groupName) throws ConfigException
    {
        return s_cfgProperties.getProperties(filePath, groupName);
    }

    /**
     * Returns a Collection of CxxProperties from the specified list of groups.
     * 
     * @param groupNames
     * @return A Collection of CxxProperties objects.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupNames is null or empty
     */
    public static Collection<CxxProperties> getProperties(Collection<String> groupNames) throws ConfigException
    {
        return s_cfgProperties.getProperties(groupNames);
    }

    /**
     * Returns a Collection of CxxProperties from the specified list of groups, using the filepath
     * as the directory to retrieve the properties. The filepath is only used for file-based
     * implementations. In the config server implementation the filepath is ignored.
     * 
     * @param filePath
     * @param groupNames
     * @return A Collection of CxxProperties objects.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupNames is null or empty
     * @throws IllegalArgumentException
     *             if filePath is null or empty
     */
    public static Collection<CxxProperties> getProperties(String filePath, Collection<String> groupNames) throws ConfigException
    {
        return s_cfgProperties.getProperties(filePath, groupNames);
    }

    /**
     * Returns the properties from the specified list of groups.
     * 
     * @param groupNames
     * @return A GroupMap object.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupNames is null or empty
     */
    public static GroupMap getPropertiesMap(Collection<String> groupNames) throws ConfigException
    {
        return s_cfgProperties.getPropertiesMap(groupNames);
    }

    /**
     * Returns the properties from the specified list of groups, using the filepath as the directory
     * to retrieve the properties. The filepath is only used for file-based implementations. In the
     * config server implementation the filepath is ignored.
     * 
     * @param filePath
     * @param groupNames
     * @return A GroupMap object.
     * @throws ConfigException
     *             If there were issues retrieving the properties
     * @throws ResourceNotFoundException
     *             If the specified resource does not exist or is is not assigned to an hln
     * @throws IllegalArgumentException
     *             if groupNames is null or empty
     * @throws IllegalArgumentException
     *             if filePath is null or empty
     */
    public static GroupMap getPropertiesMap(String filePath, Collection<String> groupNames) throws ConfigException
    {
        return s_cfgProperties.getPropertiesMap(filePath, groupNames);
    }

}
